package com.blue.integration.spring.convertor;

import java.sql.Timestamp;

import org.springframework.core.convert.converter.Converter;

/**
 * 字符串转化为SQL时间戳
 * 
 * @author zhengj
 * @since 1.0 2016年7月16日
 */
public class StringToSqlTimestampConvertor implements Converter<String, Timestamp>
{
	public StringToSqlTimestampConvertor()
	{
	}

	@Override
	public Timestamp convert(String text)
	{
		if (text == null || text.isEmpty())
			return null;
		
		if (text.indexOf(" ") == -1)
			text += " 00:00:00";

		return Timestamp.valueOf(text);
	}
}
